# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname="jsoncpp"
pkgver=1.6.2
pkgrel=1
pkgdesc="A C++ library for interacting with JSON"
arch=('any')
url="https://github.com/open-source-parsers/jsoncpp"
license=('MIT')
makedepends=("gcc"
             "cmake"
             "python2"
            )
options=('staticlibs' '!strip' '!buildflags')
source=("https://github.com/open-source-parsers/jsoncpp/archive/$pkgver.tar.gz"
        "snprintf-newlib.patch")
md5sums=('5a62da8b5c5b0e46a0e782e7363aee3d'
         '34829bc0fc597234537f376eb2762a6d')

prepare() {
  cd "${srcdir}/${pkgname}-$pkgver"
    patch -p1 -i ${srcdir}/snprintf-newlib.patch
}

build() {
  mkdir "${srcdir}/build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX:PATH="${pkgdir}" \
    -DCMAKE_BUILD_TYPE=Release \
    -DJSONCPP_WITH_CMAKE_PACKAGE=ON \
    "${srcdir}/${pkgname}-$pkgver"

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make install
}
